package day06;

import java.util.concurrent.TimeUnit;

/**
 * @author: 王丹
 * @create: 2021-06-30 22:45
 * 线程中断
 * public void  interrupt() //中断线程
 * public boolean isInterrupted()//判断线程是否被中断
 * public static boolean interrupted()//判断线程是否被中断，并清除当前中断状态
 **/

public class Demo02 {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    // todo
//                    if (this.interrupted()){
//
//                    }
                }
            }
        });
        thread.start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        thread.interrupt();
    }
}
